﻿using System;
using System.Data.Linq.Mapping;

namespace BSU.CSCE.Data.Model
{
    [Serializable]
    [Table(Name = "User")]
    public class User : IEntity<int>
    {
        public User()
        {
            Id = -1;
        }

        [Column(Name = "id", DbType = "Int IDENTITY", IsPrimaryKey = true,
            IsDbGenerated = true, CanBeNull = false,
            AutoSync = AutoSync.OnInsert, UpdateCheck = UpdateCheck.Never)]
        public int Id { get; set; }

        //[NotNullOrEmptyValidator(Ruleset = "AllUserTypes", MessageTemplateResourceName = "NotNullOrEmptyValidator", MessageTemplateResourceType = typeof(ValidationMessages))]
        [Column(Name = "firstName", DbType = "NVarChar(35)", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        public string FirstName { get; set; }

        [Column(Name = "middleName", DbType = "NVarChar(35)", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        public string MiddleName { get; set; }

        //[NotNullOrEmptyValidator(Ruleset = "EndUserOrPartyUser", MessageTemplateResourceName = "NotNullOrEmptyValidator", MessageTemplateResourceType = typeof(ValidationMessages))]
        [Column(Name = "lastName", DbType = "NVarChar(35)", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        public string LastName { get; set; }

        public string DisplayName
        {
            get
            {
                return string.Format("{0} {1} {2}", FirstName, MiddleName, LastName);
            }
        }

        [Column(Name = "status", DbType = "int", CanBeNull = false, UpdateCheck = UpdateCheck.Never)]
        public UserStatus Status { get; set; }
    }
}
